<!DOCTYPE html>
<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script th:src="@{/js/jquery-3.5.1.min.js}" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" th:href="@{/layui-v2.6.4/layui/css/layui.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/layui-v2.6.4/layui/css/modules/code.css}"/>
    <script th:src="@{/layui-v2.6.4/layui/layui.js}" type="text/javascript" charset="utf-8"></script>
    <script th:src="@{/js/angular.min.js}" type="text/javascript"></script>
    <script type="text/javascript">
        var app = angular.module("cems", []);
        app.controller("changePassowrdController", function ($scope, $http) {
            $scope.changePassword = function () {
                if($scope.p1!=''&&$scope.p2!=''&&$scope.p3!=''){
                    if ($scope.p1 == $scope.p2) {
                        layer.msg("新密码不能与旧密码一样");
                    } else {
                        if ($scope.p2 != $scope.p3) {
                            layer.msg("两次密码不一致");
                        } else {

                            $http.get("/admin/changePassword?oldPwd=" + $scope.p1 + "&newPwd=" + $scope.p2).success(function (response) {
                                layer.msg(response);
                                $scope.p1='';
                                $scope.p2='';
                                $scope.p3='';
                            });
                        }
                    }
                }else{
                    alert("不能为空值");
                }

            }
        });
    </script>
</head>
<body ng-app="cems" ng-controller="changePassowrdController" ng-init="p1='';p2='';p3='';" th:align="center">

<h1 align="left">修改密码</h1>
<hr>
<div class="layui-row">
    <div class="layui-form-item layui-col-md4 layui-col-md-offset0">
        <label class="layui-form-label">旧密码</label>
        <div class="layui-input-inline">
            <input type="password" ng-model="p1" required lay-verify="required" placeholder="请输入旧密码" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux" ng-if="{{p1==''}}">请输入旧密码</div>
    </div>

    <div class="layui-form-item layui-col-md4 layui-col-md-offset0">
        <label class="layui-form-label">新密码</label>
        <div class="layui-input-inline">
            <input type="password" ng-model="p2" required lay-verify="required" placeholder="请输入新密码" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux" ng-if="{{p2==''}}">请输入新密码</div>
    </div>

    <div class="layui-form-item layui-col-md4 layui-col-md-offset0">
        <label class="layui-form-label">新密码</label>
        <div class="layui-input-inline">
            <input type="password" ng-model="p3" required lay-verify="required" placeholder="请再次输入新密码" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux" ng-if="{{p3==''}}">请再次输入新密码</div>
    </div>

    <div class="layui-form-item layui-col-md4 layui-col-md-offset0">
        <div class="layui-input-block">
            <button class="layui-btn" ng-click="changePassword()">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</div>
</body>
</html>